home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / ansi_130.zip / PINGANSI.DOC < prev    next >
Text File  |  1990-06-03  |  7KB  |  205 lines

  1. PingAnsi v1.30 (c) CopyRight 1990 P.H.Rankin Hansen.
  2. Musica v1.00 (c) CopyRight 1990 P.H.Rankin Hansen.
  3.  
  4. The  PingAnsi  unit  provides  partial  Ansi  emulation for Turbo
  5. Pascal  versions  5.x  and  higher.  (version  4 does not support
  6. procedural types). Some routines may be handled in a non-standard
  7. way.
  8.  
  9. The Musica unit implements the Play statement known from Basic.
  10.  
  11. Released in Denmark on June 3rd 1990.
  12.  
  13. By  using this  material You  assume FULL  responsibility for ANY
  14. consequences  -  direct  or  indirect  -  thereof.
  15.  
  16. Any dispute  regarding this material shall  be setteled by Danish
  17. law and in a Danish Court.
  18.  
  19. (Sigh!)
  20.  
  21. This source may  NOT be used by Lawyers,  Politicians or, persons
  22. engaged in  any other form  of terrorism. Otherwise  the usage is
  23. free.
  24.  
  25. This source may be freely distributed as long as no fee is charged.
  26.  
  27.  
  28.  
  29.                         Acknowlegdements:
  30.  
  31. The  text file  device driver  mechanism was  suggested by Robert
  32. Mashlan.
  33.  
  34. The so called 'Ansi'-music is due to steady prompting and lots of
  35. small hints from Dan Wulff, Dragons Lair (2:231/57.0)
  36.  
  37. In creating the  units I have used Turbo  Pascal 5.5 Professional
  38. (Borland),  Turbo  Analyst  5.04  and  Turbo Professional Toolbox
  39. 5.07 (Turbo Power).
  40.  
  41. The units were  written to end the steady  stream of questions in
  42. the  international  Pascal  echo  about  how  to  implement  Ansi
  43. emulation with turbo Pascal. Sofar it looks like it has increased
  44. the number.
  45.  
  46.  
  47.  
  48.                          Using the units:
  49.  
  50. (This is a preliminary document and NOT complete ! )
  51.  
  52. First  let  me  make  one  thing  prefectly  clear.  If You issue
  53. grabtimer function in  the Musica unit, the 8253  timer 0 will be
  54. re-programmed to a 1 ms period. Therefore Interrupt 8 occurs 1000
  55. times a second  instead of 18.2 times. The  original interrupt is
  56. called only once every 55  interrupts and the system is therefore
  57. operating like usual. If You  have other routines that re-program
  58. timer 0 the result will propably be less than impressing. Keep in
  59. mind that problems may also occur  if a TSR with memory-swap pops
  60. up on top  of the interrupt handler. You  can normalize the timer
  61. and release the interrupt using the procedure ReleaseTimer.
  62.  
  63. First  You have  to decide  how You  are going  to use the units.
  64. There are three conditionals (Small,  BBS and, Music) that govern
  65. the function of PingAnsi.
  66.  
  67. The  conditional  'Small'  defines  wether  the  Text File device
  68. driver should be included. The  Device driver will  be slower for
  69. single  characters, but  presumably  faster  for strings.  If You
  70. define  'Small' the  driver part   will be  left out.  Wether You
  71. include  the  text  file  driver  will  have  NO influence on the
  72. AnsiWrite function, only on the size of the compiled unit.
  73.  
  74. The  conditional  'BBS'  defines  wether  the  hook BBSHook(Char)
  75. should be called as well as AnsiWrite during writes. Use this for
  76. echoing all Write(Ansi,......) to e.g. the ComPort or a log file.
  77.  
  78. The  conditional 'Music'  defines wether  the Ansi  parser should
  79. check for so called Ansi music. Please note that this is NOT part
  80. of the Ansi  specs., but the name sticks and  I have been _asked_
  81. to implement  it. I have  interfaced the procedure  PlayHook(St :
  82. String) wich, using the Musica unit, can be used to implement the
  83. Play  statement  known  from  Basic.  Musica  supports background
  84. buffering of music.
  85.  
  86.  
  87.  
  88.                              HOOKS:
  89.  
  90. Several hooks besides BBSHook are implemented.
  91.  
  92. ReplyHook     : Procedure(St : String);
  93.  
  94. ReplyHook  is  a  hook  for  implementing  Your own Device Status
  95. Report  procedure. It  defaults to  a procedure  that places  the
  96. response in  the keyboard buffer,  but can be  redirected to e.g.
  97. sending the report to the comport.
  98.  
  99.   KeyHook     : Procedure(St : String);
  100.  
  101. KeyHook   is  a   hook   for   implementing  Your   own  KeyBoard
  102. Re-assignment. You could  use this in a comms.  program to report
  103. attempts to re-assign Your keyboard.
  104.  
  105.   WriteHook   : Procedure(Ch : Char);
  106.  
  107. WriteHook is a Hook for handling control chars i.e. Ord(Ch) < $20
  108.  
  109.   PlayHook : Procedure(Tone, Duration : word);
  110.  
  111. This hook is for implementing 'Ansi' music.
  112.  
  113.  
  114.  
  115.                            VARIABLES:
  116.  
  117. Several variables have been interfaced:
  118.  
  119. Ansi is the name of the Text file device driver.
  120.  
  121. Wrap is  set to true  if cursor should  wrap at the  screen edge.
  122. Defaults to true.
  123.  
  124. ReportedX are ReportedY the reported  cursor location issued by a
  125. parsed  position  report.  i.e.  if  the  string  #27[#;#R is run
  126. through the parser.
  127.  
  128.  
  129.  
  130.                     PROCEDURES AND FUNCTIONS:
  131.  
  132. Procedure AnsiWrite(Ch : Char);
  133.  
  134. This is the main routine.
  135.  
  136. Function In_Ansi : Boolean;
  137.  
  138. Returns true if a ansi sequence is pending.
  139.  
  140. Procedure AssignAnsi(Var f : Text);
  141.  
  142. This is used like AssignCrt. It  resets the driver. The driver is
  143. automatically assigned  to the file  Ansi at startup,  but You're
  144. the boss...
  145.  
  146. You handle the Text file device driver like any other write:
  147.  
  148. Write(Ansi,whatever....
  149.  
  150.  
  151.  
  152.                              Musica:
  153.  
  154. This unit can be used as a  standalone unit as it does not depend
  155. on the PingAnsi unit.
  156.  
  157. Const
  158.   WaitForEmpty : boolean = True;
  159.  
  160. Governs the  behavior of the  procedure that places  the motes in
  161. the background buffer. If set to true and the PlayBuffer is full,
  162. stuff  will wait  until space  is awailable  before returning. If
  163. false and the PlayBuffer is full, stuff will discard the note and
  164. return (buffer overrun).
  165.  
  166. Procedure Play(St : String);
  167.  
  168. Implements the parsing of the play strings.
  169.  
  170. Function PlayBufferEmpty : boolean;
  171.  
  172. Returns true if the background buffer  is empty. You can use this
  173. to prevent certain  events from taking place until  the music has
  174. finished.
  175.  
  176. e.g.
  177.  
  178.                 While Not PlayBufferEmpty do {};
  179.                 Exit;
  180.  
  181. Function PlayBufferFull : boolean;
  182.  
  183. Returns true if  the background buffer is Full.  You can use this
  184. to  prevent  buffer  overrun  (if  WaitForEmpty  is  false) or to
  185. prevent  the  system  from  beeing  'locked'  (if WaitForEmpty is
  186. True).
  187.  
  188. Function GrabTimer : Boolean;
  189.  
  190. Installs the background handler and sets up ExitProc to unload it
  191. upon exit. If  it returns false the handler  was not instaled due
  192. to an incompatible timer mode.
  193.  
  194. Procedure ReleaseTimer;
  195.  
  196. Uninstalls the background handler.
  197.  
  198.  
  199.                      CONTACTING THE AUTHOR:
  200.  
  201. Please  direct  any   comments,  corrections,  modifications  via
  202. netmail to:
  203.  
  204.            Ping Hansen - FidoNet address: 2:231/62.58
  205.